/**
 *
 * © Bahadir Zeren 2011
 * bzeren@gmail.com
 * No warranties, express or implied, are made for this program.
 *
 */

package org.baatar.remoting.message;

import java.util.ArrayList;
import java.util.Arrays;
import org.baatar.net.message.IRequest;

/**
 * Request message class is used to encapsulate the data to be sent 
 * through BaatarRemoting library. Instances of this serializable class are 
 * written to ObjectOutputStream and sent via java.net.Socket.
 * 
 * @author b_zeren
 */
public class RemoteRequest implements IRequest {

    private String clientInfo = null;
    private String operation = null;
    private ArrayList<Object> params = new ArrayList<Object>();

    /**
     * Generates a Request object based on the passed parameters.
     * 
     * @param clientInfo client information to be sent to TCP service.
     * @param operation name of the operation to be called on the TCP service.
     * 
     * @return Request generated Request object.
     */
    public RemoteRequest(String clientInfo, String operation) {
        this.clientInfo = clientInfo;
        this.operation = operation;
    }

    /**
     * Generates a Request object based on the passed parameters.
     * 
     * @param clientInfo client information to be sent to TCP service.
     * @param operation name of the operation to be called on the TCP service.
     * @param obj parameter to be sent to the TCP service.
     * 
     * @return Request generated Request object.
     */
    public RemoteRequest(String clientInfo, String operation, Object param) {
        this.clientInfo = clientInfo;
        this.operation = operation;
        this.params.add(param);
    }

    /**
     * Generates a Request object based on the passed parameters.
     * 
     * @param clientInfo client information to be sent to TCP service.
     * @param operation name of the operation to be called on the TCP service.
     * @param objs parameter list to be sent to the TCP service.
     * 
     * @return Request generated Request object.
     */
    public RemoteRequest(String clientInfo, String operation, Object... params) {
        this.clientInfo = clientInfo;
        this.operation = operation;
        this.params.addAll(Arrays.asList(params));
    }


    /**
     * Information about client which has been sending this request object.
     * 
     * @return String client information.
     * 
     */
    public String getClientInfo() {
        return clientInfo;
    }

    /**
     * Name of the operation which client wants to perform.
     * 
     * @return String name of the operation which will be performed on the 
     * remoting service.
     * 
     */
    public String getOperation() {
        return operation;
    }

    /**
     * List of the parameters to be passed to remote method on the remote 
     * service.
     * 
     * @return list of parameters.
     * 
     */
    public ArrayList<Object> getParams() {
        return params;
    }

}
